package com.mxf.code.entity.node;

import lombok.Data;
import lombok.NoArgsConstructor;
import org.neo4j.ogm.annotation.Relationship;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.neo4j.core.schema.GeneratedValue;
import org.springframework.data.neo4j.core.schema.Id;
import org.springframework.data.neo4j.core.schema.Node;
import org.springframework.data.neo4j.core.schema.Property;

import java.io.Serializable;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * @author 28382
 */
@Data
@NoArgsConstructor
@Node(labels = {"Person", "人类"})
public class Person implements Serializable {

    @Id
    @GeneratedValue
    private Long id;
    @Property(name = "name")
    private String name;
    @Property(name = "gender")
    private String gender;
    @Property(name = "age")
    private int age;
    @Property(name = "idCardNo")
    private String idCardNo;
    @Property(name = "mobile")
    private String mobile;
    @Property(name = "education")
    private String education;
    @Property(name = "occupation")
    private String occupation;
    @Property(name = "remark")
    private String remark;
    //@CreatedDate
    private String createDate;
    //@LastModifiedDate
    private String updateDate;
    @CreatedBy
    private Long creator;
    @LastModifiedBy
    private Long updater;

    @Relationship(type = "friend", direction = Relationship.UNDIRECTED)
    private Set<Person> friends = new HashSet<>();

    @Relationship(type = "ACTED_IN", direction = Relationship.INCOMING)
    private List<Roles> actorsAndRoles;

    public Person(String name) {
        this.name = name;
    }

    public void addFriend(Person friend) {
        friends.add(friend);
    }
}

